package com.trainoo.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.*;

/** 
 * <p> add description here </p>
 *        
 * @author tao.zhou
 * @date 2020/6/16 16:37:00
 * @version 1.0
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ElasticEntity {

    /**
     * 主键标识，用户ES持久化
     */
    private String id;

    /**
     * JSON对象，实际存储数据
     */
    private Map<String, Object> data;



    public static ElasticEntity getEntity(){
        Map<String, Object> date = new HashMap<>(16);
        date.put("name", "java");
        date.put("age", 14);
        date.put("birthday", new Date());
        date.put("money", 100L);
        date.put("desc", "java is the best on the world");


        ElasticEntity elasticEntity = new ElasticEntity();
        elasticEntity.setId("1123");
        elasticEntity.setData(date);
        return elasticEntity;
    }

    public static List<ElasticEntity> getListEntity(){
        Map<String, Object> date1 = new HashMap<>(16);
        date1.put("name", "java");
        date1.put("age", 14);
        date1.put("birthday", new Date());
        date1.put("money", 100L);
        date1.put("desc", "java is the best on the world");

        ElasticEntity elasticEntity1 = new ElasticEntity();
        elasticEntity1.setId("1123");
        elasticEntity1.setData(date1);

        Map<String, Object> date2 = new HashMap<>(16);
        date2.put("name", "ruby");
        date2.put("age", 14);
        date2.put("birthday", new Date());
        date2.put("money", 100L);
        date2.put("desc", "ruby is the best on the world");

        ElasticEntity elasticEntity2 = new ElasticEntity();
        elasticEntity2.setId("1124");
        elasticEntity2.setData(date2);

        Map<String, Object> date3 = new HashMap<>(16);
        date3.put("name", "python");
        date3.put("age", 15);
        date3.put("birthday", new Date());
        date3.put("money", 100L);
        date3.put("desc", "python is the best on the world");

        ElasticEntity elasticEntity3 = new ElasticEntity();
        elasticEntity3.setId("1125");
        elasticEntity3.setData(date3);

        List<ElasticEntity> list = new ArrayList<>(3);
        list.add(elasticEntity1);
        list.add(elasticEntity2);
        list.add(elasticEntity3);

        return list;
    }
}
